"use strict";

/**
 * @ngdoc service
 * @name jgappApp.modulemap
 * @description
 * # modulemap
 * Service in the jgappApp.
 */

/*
如果列表长度大于8时候根据categoryType类别来显示不同的分类背景图和连接
如果列表长度小于8时候直接显示categoryType类别下来的小分类，并且根据iconUrl值为小分类配置背景图和连接
*/

angular.module("jgappApp").factory("Modulemap", function () {
  var Modulemap = {};
  var modulemapArr = [
    {
      Other: {
        //其他
        intro: "投标、业绩、证件",
        className: "icon_grgl",
        viewName: "userdefined/index"
      }
    },
    {
      Project: {
        //经营管理
        intro: "投标、业绩、证件",
        className: "icon_jy",
        viewName: "manage/index"
      }
    },
    {
      Project_BidApply: {
        //投标申请单
        className: "icon_tb",
        viewName: "manage/tbapply",
        viewValue: "投标申请单",
        checkViewName: "manage/checktbapply"
      }
    },
    {
      Project_CustomerStore: {
        //投标申请单
        className: "icon_kuk",
        viewValue: "客户库",
        checkViewName: "manage/check_khk"
      }
    },
    {
      Project_IntroductionLetter: {
        //介绍信
        className: "icon_introletter",
        viewName: "manage/introletter",
        viewValue: "介绍信",
        checkViewName: "manage/check_introletter"
      }
    },
    {
      Chief_PerformanceApply: {
        //借业绩
        className: "icon_lend",
        viewName: "manage/lend",
        viewValue: "借业绩",
        checkViewName: "manage/check_lend"
      }
    },
    {
      Chief_PerformanceReturn: {
        //还业绩
        className: "icon_repay",
        viewName: "manage/repay",
        viewValue: "还业绩",
        checkViewName: "manage/check_reapy"
      }
    },
    {
      Chief_Performance: {
        //业绩库
        className: "icon_yjk",
        viewValue: "业绩库",
        checkViewName: "administrator/check_admin_yjk"
      }
    },
    {
      Chief_CertificateApplyNew: {
        //借证件
        className: "icon_lendid",
        viewName: "manage/lendid",
        viewValue: "借证件",
        checkViewName: "manage/check_lendid"
      }
    },
    {
      Chief_CertificateReturn: {
        //还证件
        className: "icon_repayid",
        viewName: "manage/repayid",
        viewValue: "还证件",
        checkViewName: "manage/check_reapyid"
      }
    },
    {
      Finance: {
        //财务管理
        intro: "付款、收款、借款、报销等各种财务",
        className: "icon_cw",
        viewName: "finance/index"
      }
    },
    {
      Finance_PaymentInvoice: {
        //成本发票
        className: "icon_jxfp",
        viewName: "finance/f_jxfp",
        viewValue: "成本发票",
        checkViewName: "finance/checkf_jxfp"
      }
    },
    {
      Xm_InputInvoice: {
        //进项发票
        className: "icon_jxfp",
        viewName: "finance/f_jxfp1",
        checkViewName: "finance/checkf_jxfp1"
      }
    },
    {
      Xm_OutputInvoice: {
        //销项发票
        className: "icon_jxfp",
        viewName: "finance/f_xxfp",
        checkViewName: "finance/checkf_xxfp"
      }
    },

    {
      Finance_BorrowMoney: {
        //借款单
        className: "icon_jkd",
        viewName: "finance/f_jkd",
        viewValue: "借款单",
        checkViewName: "finance/checkf_jkd"
      }
    },
    {
      Finance_PayMoney: {
        //付款单
        className: "icon_fkd",
        viewName: "finance/f_fkd",
        viewValue: "付款单",
        checkViewName: "finance/checkf_fkd"
      }
    },
    {
      Finance_OpenAccount: {
        //银行开户
        className: "icon_yhkh",
        viewName: "finance/f_yhkh",
        viewValue: "银行开户",
        checkViewName: "finance/checkf_yhkh"
      }
    },
    {
      Finance_TaxRecord: {
        //完税凭证
        className: "icon_wspz",
        viewName: "finance/f_ws",
        viewValue: "完税凭证",
        checkViewName: "finance/checkf_ws"
      }
    },
    {
      Finance_BankGuarantee: {
        //银行保函
        className: "icon_yhbh",
        viewName: "finance/f_yhbh",
        viewValue: "银行保函",
        checkViewName: "finance/checkf_yhbh"
      }
    },
    {
      Chief_CertificateCost: {
        //证件费用
        className: "icon_zjfy",
        viewName: "finance/f_zjfy",
        viewValue: "证件费用",
        checkViewName: "finance/checkf_zjfy"
      }
    },
    {
      Finance_Reimbursement: {
        //报销单
        className: "icon_bxd",
        viewName: "finance/f_bxd",
        viewValue: "报销单",
        checkViewName: "finance/checkf_bxd"
      }
    },
    {
      Finance_ProjectMoney: {
        //工程款
        className: "icon_gck",
        viewName: "finance/f_gck",
        viewValue: "工程款",
        checkViewName: "finance/checkf_gck"
      }
    },
    {
      Finance_DepositApplySingle: {
        //保证金
        className: "icon_bzj",
        viewName: "finance/f_bzj",
        viewValue: "保证金",
        checkViewName: "finance/checkf_bzj"
      }
    },
    {
      Finance_PerformanceBond: {
        //履约保证金
        className: "icon_lybzj",
        viewName: "finance/f_lybzj",
        viewValue: "履约保证金",
        checkViewName: "finance/checkf_lybzj"
      }
    },

    {
      Finance_OtherMoney: {
        //收款
        className: "icon_sk",
        viewName: "finance/f_sk",
        viewValue: "收款",
        checkViewName: "finance/checkf_sk"
      }
    },
    {
      Finance_BcompanyCost: {
        //分公司收款
        className: "icon_fgssk",
        viewValue: "分公司收款",
        checkViewName: "finance/checkf_fgssk"
      }
    },
    {
      Finance_TaxReceiptRegister: {
        //工程税票
        className: "icon_gcsp",
        viewName: "finance/f_gcsp",
        viewValue: "工程税票",
        checkViewName: "finance/checkf_gcsp"
      }
    },
    {
      Finance_AddedValueTax: {
        //增值税发票
        className: "icon_addtax",
        viewName: "finance/addvaluetax",
        viewValue: "增值税发票",
        checkViewName: "finance/check_addvaluetax"
      }
    },
    {
      Finance_TaxDeduction: {
        //增值税发票
        className: "icon_zzsdk",
        viewName: "finance/f_zzsdk",
        viewValue: "增值税发票",
        checkViewName: "finance/checkf_zzsdk"
      }
    },
    {
      Project_BidNotice: {
        //投标公示栏
        className: "icon_tbggl",
        viewName: "manage/bidnotice",
        viewValue: "投标公示栏",
        checkViewName: "manage/check_bidnotice"
      }
    },
    {
      Finance_SendDepositApply: {
        //汇保证金
        className: "icon_bzj",
        viewName: "finance/SendDepositApply",
        viewValue: "汇保证金",
        checkViewName: "finance/check_SendDepositApply"
      }
    },
    {
      Finance_BackDepositApply: {
        //退保证金
        className: "icon_bzj",
        viewName: "finance/BackDepositApply",
        viewValue: "退保证金",
        checkViewName: "finance/check_BackDepositApply"
      }
    },
    {
      Project_BidChargeSingle: {
        //投标费收款
        className: "icon_tbfsk",
        viewName: "manage/bidcharge",
        viewValue: "投标费收款",
        checkViewName: "finance/checkf_tbfsk"
      }
    },
    {
      Finance_ManagermentCharge: {
        //管理费收款
        className: "icon_glfsk",
        viewValue: "管理费收款",
        checkViewName: "finance/checkf_glfsk"
      }
    },
    {
      Finance_OutRun: {
        //外经证
        className: "icon_wjz",
        viewName: "finance/f_wjz",
        viewValue: "外经证",
        checkViewName: "finance/checkf_wjz"
      }
    },
    {
      Personnel: {
        //人事管理
        intro: "出差、请假、加班、调休等人事申请",
        viewName: "personnel/index",
        className: "icon_rs"
      }
    },
    {
      Personnel_TravelApply: {
        //出差条
        className: "icon_cc",
        viewName: "personnel/cctip",
        viewValue: "出差条",
        checkViewName: "personnel/checkcctip"
      }
    },
    {
      Personnel_BdApply: {
        //补登条
        className: "icon_bd",
        viewName: "personnel/bdtip",
        viewValue: "补登条",
        checkViewName: "personnel/checkbdtip"
      }
    },
    {
      Personnel_Leave: {
        //请假条
        className: "icon_qj",
        viewName: "personnel/qjtip",
        viewValue: "请假条",
        checkViewName: "personnel/checkqjtip"
      }
    },
    {
      Personnel_SalaryApply: {
        //工资条
        className: "icon_gz",
        viewValue: "工资条",
        checkViewName: "personnel/checkgztip"
      }
    },
    {
      Personnel_PayrollApply: {
        //工资表
        className: "icon_gz",
        viewValue: "工资表",
        checkViewName: "personnel/checkgztable"
      }
    },
    {
      Project_CommisionApply: {
        //提成申请
        className: "icon_tcsq",
        viewName: "personnel/tcsqtip",
        viewValue: "提成申请",
        checkViewName: "personnel/checkyjtc"
      }
    },
    {
      Personnel_OvertimeApply: {
        //加班条
        className: "icon_jb",
        viewName: "personnel/jbtip",
        viewValue: "加班条",
        checkViewName: "personnel/checkjbtip"
      }
    },
    {
      Personnel_DaysoffApply: {
        //补休条
        className: "icon_tx",
        viewName: "personnel/txtip",
        viewValue: "补休条",
        checkViewName: "personnel/checktxtip"
      }
    },
    {
      Personnel_CaseRegister: {
        //案件登记
        className: "icon_ajdj",
        viewValue: "案件登记",
        viewName: "personnel/ajdj",
        checkViewName: "personnel/checkandj"
      }
    },
    {
      Personnel_UseCar: {
        //用车申请
        className: "icon_ycsq",
        viewName: "personnel/ycsq",
        viewValue: "用车申请",
        checkViewName: "personnel/checkycsq",
        returnViewName: "personnel/returnycsq"
      }
    },
    {
      Project_AttendanceApply: {
        //出场申请
        className: "icon_newtask",
        viewName: "personnel/ccsq",
        viewValue: "出场申请",
        checkViewName: "personnel/checkccsq"
      }
    },
    {
      Personnel_GoOut: {
        //外出办事
        className: "icon_wcbs",
        viewName: "personnel/wcbs",
        viewValue: "外出办事",
        checkViewName: "personnel/checkwcbs"
      }
    },
    {
      Personnel_Archives: {
        //人事档案
        className: "icon_wcbs",
        // viewName: "personnel/rsda",
        checkViewName: "personnel/checkrsda"
      }
    },
    {
      Chief: {
        //行政管理
        intro: "通知发文、办消证件、印章相关",
        className: "icon_xz",
        viewName: "administrator/index"
      }
    },
    {
      Chief_Certificate: {
        //证件库
        className: "icon_zjk",
        viewValue: "证件库",
        checkViewName: "administrator/check_admin_zjk"
      }
    },
    {
      Chief_BorrowMaterial: {
        //借物资
        className: "icon_jwz",
        viewName: "administrator/admin_jwz",
        checkViewName: "administrator/check_admin_jwz"
      }
    },
    {
      Chief_BuyMaterial: {
        //采购物资
        className: "icon_jwz",
        viewName: "administrator/admin_cgwz",
        checkViewName: "administrator/check_admin_cgwz"
      }
    },
    {
      Chief_ReturnMaterial: {
        //还物资
        className: "icon_hwz",
        viewName: "administrator/admin_hwz",
        checkViewName: "administrator/check_admin_hwz"
      }
    },
    {
      Chief_StockMaterial: {
        //物资入库
        className: "icon_hwz",
        // viewName: "administrator/admin_hwz",
        checkViewName: "administrator/check_admin_wzrk"
      }
    },
    {
      Chief_CommonStore: {
        //物资库
        className: "icon_wzk",
        checkViewName: "administrator/check_admin_wzk"
      }
    },
    {
      Chief_SealStore: {
        //印章库
        className: "icon_yzk",
        viewValue: "印章库",
        checkViewName: "administrator/check_admin_yzk"
      }
    },
    {
      Project_WinBid: {
        //中标公示栏
        className: "icon_zbgsl",
        viewValue: "中标公示栏",
        checkViewName: "administrator/check_admin_zbgsl"
      }
    },
    {
      Other_Placard: {
        //公告栏
        className: "icon_ggl",
        viewValue: "公告栏",
        checkViewName: "administrator/check_admin_ggl"
      }
    },
    {
      Chief_CertificateDeal: {
        //办证件
        className: "icon_bz",
        viewName: "administrator/admin_bz",
        viewValue: "办证件",
        checkViewName: "administrator/check_admin_bz"
      }
    },
    {
      Chief_ReturnSeal: {
        //还印章
        className: "icon_hyz",
        viewName: "administrator/admin_hyz",
        viewValue: "还印章",
        checkViewName: "administrator/check_admin_hyz"
      }
    },
    {
      Chief_BorrowSeal: {
        //借印章
        className: "icon_jyz",
        viewName: "administrator/admin_jyz",
        viewValue: "借印章",
        checkViewName: "administrator/check_admin_jyz"
      }
    },
    {
      Chief_CarveSeal: {
        //刻印章
        className: "icon_kyz",
        viewName: "administrator/admin_kyz",
        viewValue: "刻印章",
        checkViewName: "administrator/check_admin_kyz"
      }
    },
    {
      Chief_PublicDoc: {
        //通知发文
        className: "icon_tzfw",
        viewName: "administrator/admin_tzfw",
        viewValue: "通知发文",
        checkViewName: "administrator/check_admin_tzfw"
      }
    },
    {
      Chief_DestorySeal: {
        //印章注销
        className: "icon_yzzx",
        // viewName: "administrator/admin_yzzx",
        viewValue: "印章注销",
        checkViewName: "administrator/check_admin_yzzx"
      }
    },
    {
      Chief_CertificateTransfer: {
        //证件转出注销
        className: "icon_zjzczx",
        viewName: "administrator/admin_zjzczx",
        viewValue: "投标申请单",
        checkViewName: "administrator/check_admin_zjzczx"
      }
    },
    {
      Chief_UseSeal: {
        //用印登记
        className: "icon_yysq",
        viewName: "administrator/admin_yydj",
        viewValue: "用印登记",
        checkViewName: "administrator/check_admin_yydj"
      }
    },
    {
      Chief_CertificateShift: {
        //证件调配
        className: "icon_zjdp",
        viewName: "administrator/admin_zjdp",
        viewValue: "证件调配",
        checkViewName: "administrator/check_admin_zjdp"
      }
    },
    {
      Contract: {
        //合同管理
        intro: "工程、证件、分公司合同",
        className: "icon_ht",
        viewName: "contract/index"
      }
    },
    {
      Contract_GodownEntry: {
        //入库单
        className: "icon_rkd",
        viewName: "contract/rktiket",
        viewValue: "入库单",
        checkViewName: "contract/checkrktiket"
      }
    },
    {
      Contract_CommonContract: {
        //通用合同
        className: "icon_tyht",
        viewName: "contract/tycontract",
        viewValue: "通用合同",
        checkViewName: "contract/checktycontract"
      }
    },
    {
      Project_ContractApplySingle: {
        //工程合同
        className: "icon_ht1",
        viewName: "contract/gccontract",
        viewValue: "工程合同",
        checkViewName: "contract/checkgccontract"
      }
    },
    {
      Chief_AgreementApply: {
        //证件合同
        className: "icon_ht2",
        viewName: "contract/zjcontract",
        viewValue: "证件合同",
        checkViewName: "contract/checkzjcontract"
      }
    },
    {
      Contract_BcompanyContract: {
        //分公司合同
        className: "icon_ht3",
        viewName: "contract/fgscontract",
        viewValue: "分公司合同",
        checkViewName: "contract/checkfgscontract"
      }
    },
    {
      Xm_ContractPurchase: {
        //采购合同
        className: "icon_ht3",
        viewName: "contract/cgcontract",
        checkViewName: "contract/checkcgcontract"
      }
    },
    {
      Xm_ContractRent: {
        //租赁合同
        className: "icon_ht3",
        viewName: "contract/zlcontract",
        checkViewName: "contract/checkzlcontract"
      }
    },
    {
      Xm_ContractSubpackage: {
        //分包合同
        className: "icon_ht3",
        viewName: "contract/fbcontract",
        checkViewName: "contract/checkfbcontract"
      }
    },
    {
      Xm_ContractOther: {
        //其他合同
        className: "icon_ht3",
        viewName: "contract/qtcontract",
        checkViewName: "contract/checkqtcontract"
      }
    },
    {
      Other_CaduitObject: {
        //自定义流程
        className: "icon_zdylc",
        viewName: "userdefined/userdefined",
        viewValue: "自定义流程",
        checkViewName: "userdefined/check_userdefined"
      }
    },
    {
      Xm_ProjectStore: {
        //项目信息
        className: "icon_zdylc",
        viewName: "project/projectinfo",
        checkViewName: "project/check_projectinfo"
      }
    },
    {
      Xm_ProjectGathering: {
        //项目收款
        className: "icon_zdylc",
        viewName: "project/gathering",
        checkViewName: "project/check_gathering"
      }
    },
    {
      Xm_ProjectRefund: {
        //项目退款
        className: "icon_zdylc",
        viewName: "project/refund",
        checkViewName: "project/check_refund"
      }
    },
    {
      Xm_ProjectPayment: {
        //项目付款
        className: "icon_zdylc",
        viewName: "project/payment",
        checkViewName: "project/check_payment"
      }
    },
    {
      Xm_ProjectCost: {
        //项目扣款
        className: "icon_zdylc",
        viewName: "project/deduct",
        checkViewName: "project/check_deduct"
      }
    },
    {
      Xm_ProjectRepay: {
        //项目清账
        className: "icon_xmqz",
        viewName: "project/balance",
        checkViewName: "project/check_balance"
      }
    },
    {
      Xm_ProjectTransfer: {
        //项目余额调拨
        className: "icon_xmqz",
        checkViewName: "project/check_transfer"
      }
    },
    {
      Xm_SupplierStore: {
        //供应商
        className: "icon_xmqz",
        viewName: "project/supplier",
        checkViewName: "project/check_supplier"
      }
    },
    {
      Xm_TaxesPayment: {
        //缴税记录
        className: "icon_xmqz",
        viewName: "project/taxpayment",
        checkViewName: "project/check_taxpayment"
      }
    },
    {
      Xm_SupplementContract: {
        //补充协议
        className: "icon_xmqz",
        viewName: "project/bcxy",
        checkViewName: "project/check_bcxy"
      }
    },
    {
      Xm_ProjectBorrowing: {
        //项目借款
        className: "icon_xmqz",
        viewName: "project/projectjk",
        checkViewName: "project/check_projectjk"
      }
    },
    {
      Xm_ProjectReimburse: {
        //项目报销
        className: "icon_xmqz",
        viewName: "project/projectbx",
        checkViewName: "project/check_projectbx"
      }
    },
    {
      Xm_ProjectSettlement: {
        //项目结算
        className: "icon_xmqz",
        viewName: "project/projectjs",
        checkViewName: "project/check_projectjs"
      }
    },
    {
      Xm_ProjectDeposit: {
        //项目保证金
        className: "icon_xmqz",
        // viewName: "project/projectjs",
        checkViewName: "project/check_projectbzj"
      }
    },
    {
      Xm_CreditRefund: {
        //项目抵税扣税
        className: "icon_xmqz",
        // viewName: "project/projectjs",
        checkViewName: "project/check_projectdsks"
      }
    },
    {
      Xm_MigrantWages: {
        //项目抵税扣税
        className: "icon_xmqz",
        viewName: "project/farmerPay",
        checkViewName: "project/checkfarmerPay"
      }
    },
    {
      Material_MaterialWarehouse: {
        //材料仓库
        checkViewName: "material/check_warehouse"
      }
    },
    {
      Material_MaterialPurchase: {
        //材料采购
        viewName: "material/purchase",
        checkViewName: "material/check_purchase"
      }
    },
    {
      Material_MaterialEntering: {
        //材料入库	
        viewName: "material/entering",
        checkViewName: "material/check_entering"
      }
    },
    {
      Material_MaterialPicking: {
        //材料出库	
        checkViewName: "material/check_picking"
      }
    },
    {
      Material_MaterialReturn: {
        //材料退库	
        checkViewName: "material/check_return"
      }
    },
    {
      Material_MaterialCheck: {
        //材料盘点	
        checkViewName: "material/check_check"
      }
    },
    {
      Material_MaterialAccount: {
        //材料对账	
        checkViewName: "material/check_account"
      }
    },
    {
      Material_MaterialOrder: {
        //材料订单	
        checkViewName: "material/check_order"
      }
    },
    {
      Material_MaterialAllocate: {
        //材料调拨	
        checkViewName: "material/check_allocate"
      }
    },
  ];
  var workModulemapArr = [
    {
      moduleType: 1,
      viewValue: "考勤",
      viewName: "/attendance/index"
    },
    {
      moduleType: 2,
      viewValue: "签到",
      viewName: "/sign/index"
    },
    {
      moduleType: 3,
      viewValue: "工作任务",
      detailValue: "任务详情",
      detailView: "/task/taskdetail",
      viewName: "/task/mytask"
    },
    {
      moduleType: 4,
      viewValue: "工作报告",
      detailValue: "报告详情",
      detailView: "/task/reportdetail/3",
      viewName: "/task/taskreport"
    },
    {
      moduleType: 5,
      viewValue: "系统通知",
      detailValue: "通知详情",
      detailView: "/work/systemnotice",
      viewName: "/work/systemnotice"
    },
    {
      moduleType: 6,
      viewValue: "意见反馈",
      viewName: "/user/feedback"
    }
  ];
  Modulemap.modulemapArr = modulemapArr;
  Modulemap.workModulemapArr = workModulemapArr;
  Modulemap.getViewNameAndIcon = function (name) {
    var obj = "";
    this.modulemapArr.forEach(function (item, index, key) {
      if (item[name]) {
        obj = item[name];
        return obj;
      }
    });
    return obj;
  };
  /**
   * 根据formkey将当前流程视图传进去
   * @param  {[type]} data [流程数据]
   * @param  {[type]} name [formkey]
   * @return [type]        [包含视图的流程数据]
   */
  Modulemap.getviewData = function (data, formkey) {
    var obj;
    obj = Modulemap.getViewNameAndIcon(formkey);
    data.viewName = obj.viewName;
    data.className = obj.className;
    return data;
  };
  /**
   * 根据formkey获取当前流程名字
   * @param  {[type]} name [formkey]
   * @return [type]        [视图名]
   */
  Modulemap.getViewName = function (formkey) {
    var obj;
    obj = Modulemap.getViewNameAndIcon(formkey);
    return obj.viewValue;
  };
  // android传递过来用来判断视图是由哪里进来的
  // 传id则进入详情，不传id则进入列表
  Modulemap.getModuleViewFromModuleType = function (type, viewid) {
    var viewName;
    this.workModulemapArr.forEach(function (item, index) {
      if (item.moduleType == type) {
        if (viewid) {
          viewName = item.detailView + "/" + viewid;
        } else {
          viewName = item.viewName;
        }
        return viewName;
      }
    });
    return viewName;
  };
  /**
   * 获取模块名称
   * @param  {[type]} moduleType [模块id]
   * @return [type]           [模块名]
   */
  Modulemap.getModuleValueFromModuleType = function (type, viewid) {
    var viewName;
    this.workModulemapArr.forEach(function (item, index) {
      if (item.moduleType == type) {
        if (viewid) {
          viewName = item.detailValue;
        } else {
          viewName = item.viewValue;
        }
        return viewName;
      }
    });
    return viewName;
  };
  return Modulemap;
});
